/* $Id: UserAnnouncementFacadeImpl.java 
 * Copyright (C) 2011, TRAKHEES
 *  
 * Revision History
 *
 * Date  			Author 		    	Remarks
 * ---------------------------------------------------------------------------------
 *
 */
package ae.pcfc.etks.online.common.facade.provider;

import java.util.ArrayList;
import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import ae.pcfc.etks.online.common.domain.UserAnnouncements;
import ae.pcfc.etks.online.common.domain.manager.UserAnnouncementDomainObjectManager;
import ae.pcfc.etks.online.common.facade.UserAnnouncementFacade;
import ae.pcfc.etks.online.common.vo.UserAnnouncementVO;

public class UserAnnouncementFacadeImpl extends BaseFacade implements UserAnnouncementFacade{
    	/*
	 * Here we coordinate between the all interacting business domain objects
	 * (BO), transactions are maintained here. use case business validation are
	 * maintained here (that requires DB checks or retrieving data from DB)
	 */
	private UserAnnouncementDomainObjectManager userAnnouncementDomainObjectManager;
	
	/**
	 * setUserAnnouncementDomainObjectManager
	 * 
	 * @param userAnnouncementDomainObjectManager
	 * void
	 */
	public void setUserAnnouncementDomainObjectManager(UserAnnouncementDomainObjectManager userAnnouncementDomainObjectManager) {
		this.userAnnouncementDomainObjectManager = userAnnouncementDomainObjectManager;
	}



	/**
	 * findUserAnnouncementsByUserName
	 * 
	 * @see ae.pcfc.etks.online.common.facade.UserAnnouncementFacade#findUserAnnouncementsByUserName(java.lang.String)
	 * 
	 */
	@Transactional(readOnly = true)
	public List<UserAnnouncementVO> findUserAnnouncementsByUserName(String userName) {
		
		List<UserAnnouncements> userAnnouncements = this.userAnnouncementDomainObjectManager.findUserAnnouncementsByUserName(userName);
		
		List<UserAnnouncementVO> list = null;
		UserAnnouncementVO userAnnouncementVO;
		
		if(userAnnouncements != null && userAnnouncements.size() > 0)
		{
			list = new ArrayList<UserAnnouncementVO>();
			for(UserAnnouncements announcements: userAnnouncements){
				
				userAnnouncementVO = new UserAnnouncementVO();
				getMapper().map(announcements, userAnnouncementVO);
				list.add(userAnnouncementVO);
			}
		}
		
		
		return (list != null && list.size() > 0)? list : null;
	}

}
